// 我的订单点击展开
$(".shop-expand").on("click", function () {
    $(".shop-my-order>.shop-main").toggleClass("shop-active");
    $(".shop-expand").toggleClass("shop-turn-on")
});

// 打开物流明细
$(".shop-basic-information .shop-btm").on("click", function(){
    $(this).find(".shop-logistics-details").toggle()
});




//轮播图
var carouselMap = {}
carouselMap.MapInit = function (map, obj) {
    obj.index = 0;
    obj.w = map.width();
    obj.its = map.find(".items");
    obj.it = map.find(".item");
    map.css({ "position": "relative" });
    obj.its.css({ "width": 2 * obj.w, "height": "100%", "position": "absolute" });
    obj.it.css({ "width": obj.w, "height": "100%", "position": "absolute", "left": 2 * obj.w });
    obj.it.eq(0).css({ "left": "0px" });
}
carouselMap.Jump = function (obj, index) {
    index > obj.it.length - 1 ? index = 0 : index
    index < 0 ? index = obj.it.length - 1 : index
    if (index == obj.index) {
        return index
    } else {
        
        obj.it.css({ "left": 2 * obj.w });
        if (index > obj.index || index == obj.it.length - 1) {
            obj.its.css({ "left": "0px" });
            obj.it.eq(obj.index).css({ "left": "0px" });
            obj.index = index;
            obj.it.eq(obj.index).css({ "left": obj.w + "px" });
            obj.its.animate({ "left": -(obj.w) + "px" })
        } else if (index < obj.index || index == 0) {
            obj.its.css({ "left": -(obj.w) + "px" });
            obj.it.eq(obj.index).css({ "left": obj.w + "px" })
            obj.index = index;
            obj.it.eq(obj.index).css({ "left": "0px" });
            obj.its.animate({ "left": "0px" })
        }
        return obj.index
    }

}

// 更新选择
function UpdatePoint(Selector, obj){
    Selector.each(function(){
        $(this).removeClass("shop-selected")
    });
    Selector.eq(obj.index).addClass("shop-selected")
}


//浏览记录轮播图
carouselMap.browseRecord = {}
carouselMap.MapInit($(".shop-carousel-map1"), carouselMap.browseRecord);
$(".shop-carousel-map1 .shop-control-left").on("click", function(){
    carouselMap.Jump(carouselMap.browseRecord, carouselMap.browseRecord.index - 1);
    UpdatePoint($(".shop-carousel-map1 .shop-control-num span"), carouselMap.browseRecord);
})
$(".shop-carousel-map1 .shop-control-right").on("click", function(){
    carouselMap.Jump(carouselMap.browseRecord, carouselMap.browseRecord.index + 1);
    UpdatePoint($(".shop-carousel-map1 .shop-control-num span"), carouselMap.browseRecord);
})
$(".shop-carousel-map1 .shop-control-num span").on("click", function(){
    carouselMap.Jump(carouselMap.browseRecord, $(this).index());
    UpdatePoint($(".shop-carousel-map1 .shop-control-num span"), carouselMap.browseRecord);
})




//常规清单轮播图
carouselMap.RegularList = {}
carouselMap.MapInit($(".shop-carousel-map2"), carouselMap.RegularList);
$(".shop-carousel-map2 .shop-control-left").on("click", function(){
    carouselMap.Jump(carouselMap.RegularList, carouselMap.RegularList.index - 1);
    UpdatePoint($(".shop-carousel-map2 .shop-control-num span"), carouselMap.RegularList);
})
$(".shop-carousel-map2 .shop-control-right").on("click", function(){
    carouselMap.Jump(carouselMap.RegularList, carouselMap.RegularList.index + 1);
    UpdatePoint($(".shop-carousel-map2 .shop-control-num span"), carouselMap.RegularList);
})
$(".shop-carousel-map2 .shop-control-num span").on("click", function(){
    carouselMap.Jump(carouselMap.RegularList, $(this).index());
    UpdatePoint($(".shop-carousel-map2 .shop-control-num span"), carouselMap.RegularList);
})



